#!/usr/bin/python
# -*- coding: UTF-8 -*-

# subversion info:
# $HeadURL$
# $Author$
# $Id$
# $Revision$

"""
The htpc-utils database.
"""

# External imports
from sqlobject import SQLObject, IntCol, UnicodeCol, BoolCol, MultipleJoin, \
    ForeignKey, DateTimeCol
from sqlobject.sqlite import builder
from sqlobject import sqlhub
import datetime
import os

# Internal imports

dbFilename = os.path.expanduser(os.path.join('~', '.htpc-utils.db'))
sqlhub.processConnection = builder()(dbFilename)


class Event(SQLObject):
  date = DateTimeCol(default=datetime.datetime.now)
  title = UnicodeCol(length=256, notNull=True)
  description = UnicodeCol(length=512, default='')


class Subtitle(SQLObject):
  videoFile = UnicodeCol(length=256, notNull=True)
  subLanguage = UnicodeCol(length=16, notNull=True)
  addedDate = DateTimeCol(default=datetime.datetime.now)
  dueDate = DateTimeCol(default=None)
  tries = IntCol()


Event.createTable(ifNotExists=True)
Subtitle.createTable(ifNotExists=True)

